Add proper IptcProfile support in PNG#3048
Merged
JimBobSquarePants merged 1 commit intomainfrom Jan 23, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds comprehensive IPTC metadata support to PNG images, enabling reading and writing of IPTC profiles in a format compatible with industry-standard tools like ImageMagick, ExifTool, and Photoshop. The implementation wraps IPTC data in Photoshop Image Resource Blocks (IRB) for maximum interoperability.
Changes:
- Added IPTC profile reading and writing for PNG files using zTXt chunks with "Raw profile type iptc" keyword
- Implemented Photoshop IRB (8BIM) format support for IPTC data encapsulation and extraction
- Enhanced debugger experience for IPTC values with smarter display formatting for binary and text data
- Added comprehensive test coverage including round-trip encoding/decoding verification
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Images/Input/Png/iptc-profile.png | Test image containing IPTC metadata for validation |
| tests/ImageSharp.Tests/TestImages.cs | Added constant reference to new IPTC test image |
| tests/ImageSharp.Tests/Formats/Png/PngMetadataTests.cs | Added tests for IPTC decoding/encoding with round-trip verification; improved test assertions to use Assert.Equal instead of Assert.True |
| src/ImageSharp/Metadata/Profiles/IPTC/IptcValue.cs | Enhanced debugger display to show readable formats for binary tags like RecordVersion and hex for non-printable data |
| src/ImageSharp/Metadata/Profiles/IPTC/IptcRecordNumber.cs | Fixed grammar: "A Envelope" → "An Envelope", "A Application" → "An Application" |
| src/ImageSharp/Formats/Png/PngConstants.cs | Added constants for IPTC/Exif keywords, Adobe Photoshop signatures, and resource IDs |
| src/ImageSharp/Formats/Png/PngEncoderCore.cs | Implemented IPTC chunk writing with Photoshop IRB wrapping and zTXt compression |
| src/ImageSharp/Formats/Png/PngDecoderCore.cs | Implemented IPTC chunk reading with IRB extraction and hex decoding with robust whitespace handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites
Description
See #3046 for the relevant discussion.
This pull request adds full support for reading and writing IPTC metadata in PNG images, following conventions used by other image tools for interoperability. The changes introduce robust parsing and serialization of IPTC profiles, including handling for Photoshop IRB blocks, and improve debugging output for IPTC values. The most important changes are:
IPTC Metadata Support in PNG:
PngDecoderCore.cs,PngConstants.cs) [1] [2] [3] [4]PngEncoderCore.cs,PngConstants.cs) [1] [2] [3] [4]Constants and Interoperability Improvements:
PngConstantsfor IPTC/Exif profile keywords, Adobe Photoshop IRB resource IDs, and signature byte sequences to facilitate robust parsing and writing. (PngConstants.cs) [1] [2]Debugging and Developer Experience:
DebuggerDisplayforIptcValueto show human-readable or hexadecimal representations depending on the data, improving the debugging experience especially for binary tags like RecordVersion. (IptcValue.cs) [1] [2]